unit Con_Banco_Pais;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
  Db,Dbtables, TFlatButtonUnit;

type
  TFrmCon_Pais = class(TFrmConsulta)
    Label1: TLabel;
    edtNome: TEdit;
    dbgPais: TDBGrid;
    dbgPais: TDBGrid;
    procedure BtnFecharClick(Sender: TObject);
    procedure edtNomeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Ban_Codigo : String;
  end;

var
  FrmCon_Pais: TFrmCon_Pais;

implementation
Uses Dm, Biblio, clsPais;

{$R *.DFM}

var Pais           : TPais;
    tds            : Tdatasource;
    tq             : Tquery;

procedure TFrmCon_Pais.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Ban_Codigo:=tq.fieldbyname('Ban_Codigo').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_Pais.edtNomeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    edtNome.setfocus;
  end;
end;

procedure TFrmCon_Pais.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(FrmCon_Pais);
  tds.name:='dsPais';
  tq:=Tquery.create(FrmCon_Pais);
  tq.databasename:=dm.dmint.db.databasename;
  tq.name:='qPais';
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  edtnome.setfocus;
end;

procedure TFrmCon_Pais.FazConsulta;
begin
  if edtnome.text='' then
    edtnome.text := ' ';
  Pais:=TPais.Create;
  Pais.Consultar(tq,edtnome.text);
  tq.open;
  Pais.free;
  dbgPais.DataSource := tds;
  dbgPais.Refresh;
end;

end.
